package com.kaifamiao.www.demo.Do29.pm;

public class Person {
    int age;

    public void say(){
        System.out.println("person say ...");
    }

}

class Student extends Person {

    String name;

    @Override
    public void say(){
        System.out.println("student say ...");
    }

    public static void study(){
        System.out.println("study");
    }

    @Override
    public boolean equals(Object obj){
        if (obj == null){
            return false;
        }
        if (this == obj){
            return true;
        }

        // 强制类型转换 先判断

//        if (obj instanceof Student){ // Student 对象， Student 子类对象都可以
        if (obj.getClass() == Student.class){ // 只有 Student 对象才可以
            Student stu = (Student) obj;

//        return this.name.equals(stu.name) && this.age == stu.age
//                && this.hobby.equals(stu.hobby) && this.no == stu.no;
            if (this.name.equals(stu.name)){
                return true;
            }
        }

        return false;
    }

    @Override
    public int hashCode(){
        final int h = 31;
        int result = 0;
        result += h * name.hashCode();

        return result;
    }

}

class BoyStudent extends Student {}

class Teacher extends Person {}

class Boy extends Person {}

class Girl extends Person {}

